package dj.engine.panel;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

import dj.engine.drawable.DrawableText;
import dj.engine.util.Vec2f;

public class TextPanel extends Panel {

	protected DrawableText text;
	protected Color bg;
	protected TextPanel(Vec2f dimensions, Vec2f position)
	{
		this(dimensions, position, new Color(0,0,0,0));
	}
	
	public TextPanel(Vec2f dimensions, Vec2f position, Color background) {
		this(dimensions, position, background, "");
		
	}

	protected TextPanel(Vec2f dimensions, Vec2f position, Color background, String defaulttext) {
		super(dimensions, position);
		text = new DrawableText();
		text.setPosition(position);
		text.setColor(Color.WHITE);
		text.setString(defaulttext);
		bg = background;
	}
	
	
	@Override
	public void onTick(long nanosSincePreviousTick) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onDraw(Graphics2D g) {
		super.onDraw(g);
		Color curr = g.getColor();
		g.setColor(bg);
		g.fillRect((int)position.x,  (int)position.y,  (int)dimensions.x,  (int)dimensions.y);
		g.setColor(curr);
		text.onDraw(g);
	}

	@Override
	public void onKeyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onKeyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onKeyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onMouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onMousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onMouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onMouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onMouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onMouseWheelMoved(MouseWheelEvent e) {
		// TODO Auto-generated method stub
		
	}
	
	public void setData(String d)
	{
		text.setString(d);
	}
	
	@Override
	public void setPosition(Vec2f position)
	{
		super.setPosition(position);
		this.text.setPosition(position.plus(dimensions.sdiv(2)));
		
	}

}
